var IncSetupOut = function() {
	IncSetupOutThis=this;
}

IncSetupOut.prototype = {
	userLogout : function() {
		var mj = new MJson();
		var cm = new ConnectionManager();

		mj.putPub(MJson.PUB.SID, "US001");
		mj.putPub(MJson.PUB.SERVICENAME, "logout");
		mj.putParameter("osType", "osTest");
		mj.putParameter("tokenValue", "tokenTest");

		console.log("request : " + mj.getJsonString());
		cm.requestGet(mj.getJsonString(), function(jsonData) {
			console.log("성공 :: 통신");
			console.log("success :: " + JSON.stringify(jsonData));
			if (mj.checkServiceResult(jsonData)) {
				alert('로그아웃 성공');
				document.globalObj.LOGIN_DATA.isLogin = false;
				document.globalObj.LOGIN_DATA.userId = null;
				$.mobile.changePage("../inc/navi.html");
			} else {
				alert('로그아웃 실패');
			}
		}, function(e) {
			console.log("실패 :: 통신");
		});
	},
	 
	onPageShow : function() { 
		console.log("login_isauto :: " + window.localStorage.getItem(document.globalObj.STORAGE_KEY.login_isauto) + ", setup_notification :: " + window.localStorage.getItem(document.globalObj.STORAGE_KEY.setup_notification));
		if (window.localStorage.getItem(document.globalObj.STORAGE_KEY.login_isauto) == "on") {
			$("#setup_data_section").find('select:eq(0)').val("on").slider('refresh');
		} else {
			$("#setup_data_section").find('select:eq(0)').val("off").slider('refresh');
		}
		if (window.localStorage.getItem(document.globalObj.STORAGE_KEY.setup_notification) == "on") {
			$("#setup_data_section").find('select:eq(1)').val("on").slider('refresh');
		} else {
			$("#setup_data_section").find('select:eq(1)').val("off").slider('refresh');
		}
		$("#setupPopPrivacy").bind('click', function(event) {
			//개인정보 취급방침
			$.mobile.changePage("../member/pop_privacy.html");
		});
		$("#setupPopAgree").bind('click', function(event) {
			//이용약관
			$.mobile.changePage("../member/pop_agree.html");
		});
		$("#setupLogoutBtn").bind('click', function(event) {
			//회원 로그아웃
			IncSetupOutThis.userLogout();
		});
		$("#setupLoginIdSpan").text(document.globalObj.LOGIN_DATA.userId); 
		$("#setup_data_section").find('select:eq(0)').bind('change', function(event) {
		  	console.log('a');
			console.log($(this).val());
			window.localStorage.setItem(document.globalObj.STORAGE_KEY.login_isauto, $(this).val());
		});
		$("#setup_data_section").find('select:eq(1)').bind('change', function(event) {
		  	console.log('b');
			console.log($(this).val());
			window.localStorage.setItem(document.globalObj.STORAGE_KEY.setup_notification, $(this).val());
		});
		 
		 // 버전 표시
		 // 현재 버전
		 $('ul:last li:first mark').html(document.globalObj.VERSION.current);
		 // 최신 버전
		 $('ul:last li:last mark').html(document.globalObj.VERSION.newest);
		 
	}
};
